package com.ellricky.baselib.widget.calendar;

import android.content.Context;
import android.widget.TextView;

import androidx.core.content.ContextCompat;

import com.andr.common.ui.adapter.BaseRecyclerAdapter;
import com.andr.common.ui.adapter.SmartViewHolder;
import com.ellricky.baselib.R;


public class WeekDateAdapter extends BaseRecyclerAdapter<WeekDateEntity> {
    private Context mContext;
    private String[] weekTitle = {"日","一", "二", "三", "四", "五", "六"};

    private int selectedPosition = -1;// 选中的位置


    public void setSelectedPosition(int position) {
        selectedPosition = position;
        notifyDataSetChanged();
    }


    public WeekDateAdapter(Context mContext) {
        super(R.layout.base_layout_week_date_adpter);
        this.mContext = mContext;
    }


    @Override
    public void onBindViewHolder(SmartViewHolder holder, WeekDateEntity model, int position) {

        TextView tvWeekName = holder.itemView.findViewById(R.id.tvWeekName);
        TextView tvWeekNo = holder.itemView.findViewById(R.id.tvWeekDateNo);

        tvWeekName.setText(weekTitle[position]);
        tvWeekNo.setText(model.getDay());

        if (selectedPosition == position) {
            tvWeekNo.setTextColor(ContextCompat.getColor(mContext, R.color.common_main_white));
            tvWeekNo.setBackgroundResource(R.drawable.base_bg_select_date);
        } else {
            tvWeekNo.setTextColor(ContextCompat.getColor(mContext, R.color.common_main_black));
            tvWeekNo.setBackground(null);
        }

    }


}
